%%

/**
 * 
 * @author Bart Wentink & Sander Meijer
 *
 */
%class PicoScanner
%implements PicoTokenKinds
%function nextToken
%type PicoToken

%unicode
%line
%column

%{
 
  /**
   * Utility methode om een token te maken.
   * @param kind token soort
   * @see TokenKinds
   */
  private PicoToken createToken(String kind) {
    return new PicoToken(kind,yyline+1,yycolumn+1,yytext());
  }

%}

LineTerminator	= \r|\n|\r\n
WhiteSpace		= {LineTerminator} | [ \t\f]
P_CONSTANT 		= \'.\'
P_IDENTIFIER	= [a-zA-Z0-9_-]+
BEGIN			= "BEGIN"
END				= "END"
INT 			= "INT"
BOOL			= "BOOL"
DO 				= "DO"
OD				= "OD"
IF 				= "IF"
FI				= "FI"
THEN 			= "THEN"
ELSE 			= "ELSE"
PRINT 			= "PRINT"
EMPTY			= @
PLUS			= \+
TIMES			= \*
IS				= \=
SEPERATOR		= ,
INITMARK		= :
EOG 			= \.
LP              = \(
RP              = \)


%%

<YYINITIAL> {

{WhiteSpace}    {}
{P_CONSTANT}	{return createToken(P_CONSTANT);}
{BEGIN}			{return createToken(BEGIN);}
{END}			{return createToken(END);}
{INT}			{return createToken(INT);}
{BOOL}			{return createToken(BOOL);}
{DO}			{return createToken(DO);}
{OD}			{return createToken(OD);}
{IF}			{return createToken(IF);}
{FI}			{return createToken(FI);}
{THEN}			{return createToken(THEN);}
{ELSE}			{return createToken(ELSE);}
{PRINT}			{return createToken(PRINT);}
{P_IDENTIFIER}	{return createToken(P_IDENTIFIER);}
{EMPTY}			{return createToken(EMPTY);}
{PLUS}			{return createToken(PLUS);}
{TIMES}			{return createToken(TIMES);}
{IS}			{return createToken(IS);}
{SEPERATOR}		{return createToken(SEPERATOR);}
{INITMARK}		{return createToken(INITMARK);}
{EOG}			{return createToken(EOG);}
{LP}			{return createToken(LP);}
{RP}			{return createToken(RP);}



}

.|\n            {throw new RuntimeException(yytext()+" unmatched");}
